<!DOCTYPE html>
<html lang="ru">

<head>
    {% load static %}
    {% load js %}
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;700&display=swap" rel="stylesheet">
    <link rel="shortcut icon" href="{% static 'img/global/icon.png' %}" type="image/x-icon">
    <title>Архив работ</title>
    <link rel="stylesheet" href="{% static 'css/global/index.css' %}">
    <link rel="stylesheet" href="{% static 'css/projects/archive.css' %}">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script>
</head>

<body>
    <header class="header">
        <a href="{% url 'home' %}" class="logo"><img src="{% static 'img/global/long_logo.svg' %}" alt="Логотип лицея"></a>
        <nav class="nav">
            <ul class="nav-list">
                <li class="nav-item">
                    <a href="{% url 'home' %}#contests">Конкурсы</a>
                </li>
                <li class="nav-item">
                    <a href="{% url 'archive' %}">Архив работ</a>
                </li>
                <li class="nav-item">
                    <a href="{% url 'announcements' %}">Новости</a>
                </li>
            </ul>
        </nav>
        {% if user.is_authenticated %}
        <a class="user" href="{% url 'profile' %}">
            <p class="username">{{ user.username }}</p>
            <img class="avatar" src="{{ user.avatar.url }}" alt="Аватарка пользователя">
        </a>
        {% else %}
        <a class="user" href="{% url 'login' %}">
            <p class="username">Профиль</p>
            <img class="avatar" src="{% static 'img/global/avatar.png' %}" alt="Аватарка пользователя">
        </a>
        {% endif %}
        
    </header>
    <main class="main">
        <div class="filters">
            <form class="container" method="POST" action="{% url 'archive' %}">
                {% csrf_token %}
                <div class="left">
                    <div class="search">
                        <input class="search-input" type="text" placeholder="Поиск..." name="text">
                        <button class="search-button"></button>
                    </div>
                    <div class="tags">
                        <ul class="tag-list">
                            <item class="tag-item">
                                <button class="btn-tag" type="button" onclick="search_tag(this, 'nam')">Название</button>
                            </item>
                            <item class="tag-item">
                                <button class="btn-tag" type="button" onclick="search_tag(this, 'dscr')">Описание</button>
                            </item>
                            <item class="tag-item">
                                <button class="btn-tag" type="button" onclick="search_tag(this, 'teacher')">Учитель</button>
                            </item>
                            <item class="tag-item">
                                <button class="btn-tag" type="button" onclick="search_tag(this, 'student')">Ученик</button>
                            </item>
                        </ul>
                    </div>
                    <div class="filter">
                        <div style="margin-right: auto; position: relative;">
                            <input type="text" class="search-block-input form-input search-block-subjects"
                                placeholder="Введите названние предметной области">
                            <ul class="search-block-result-list"></ul>
                            <ul class="search-block-list"></ul>
                        </div>
                        <input type="hidden" class="search-block-hidden-input" name="subject" required>
                        <div class="div-list">
                            <div class="list-name">Номинация</div>
                            <input type="hidden" id="nominations-filter" name="nominations" />
                            <div class="list-names">
                                <div class="list-p">Не указано</div>
                                <ul class="list" name="nominations">
                                    <li class="list-li nominations">Не указано</li>
                                    {% for nomination in nominations %}
                                    <li class="list-li nominations">{{nomination}}</li>
                                    {% endfor %}
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="right">
                    <button class="btn filter_btn" type="submit">Применить</button>
                </div>
            </form>
        </div>

        <ul>
            {%for project in projects%}
            <li>
                <div>
                    <span>{{project.name}}</span>
                    <div>
                        {{project.description}}
                    </div>
                    <div>
                        {% if user.is_authenticated%}
                        <a href="{% url 'projects' %}?id={{project.abstruct.id}}" title="Загрузить файл"
                            class="download-link">Реферат</a>
                        {% endif %}
                        <a href="{% url 'projects' %}?id={{project.defence.id}}" title="Загрузить файл"
                            class="download-link">Защита</a>
                        <a href="{% url 'download_file' %}?file_id={{project.presentation.id}}" title="Загрузить файл"
                            class="download-link">Презентация</a>
                        {% if project.defence_video is not null%}
                        <a href="{{project.defence_video}}" title="Загрузить файл" class="download-link">Видео с
                            защиты</a>
                        {% endif %}
                    </div>
                    <div>
                        {{ project.subjects }}
                    </div>
                </div>
            </li>
            {%endfor%}
        </ul>


        <script src="{% static 'js/global/list.js' %}"></script>
        <script src="{% static 'js/projects/archive.js' %}"></script>
        <script src="{% static 'js/global/search_block.js' %}"></script>
        <script>
            list_arr = {{ subjects | js }};

        </script>
        <script src="{% static 'js/projects/create_page.js' %}"></script>
    </main>
</body>

</html>